package test.algos.sorting.quicksort;

import java.util.List;

import test.algos.sorting.SortUtil;

/**
 * @author mahobalan
 * 
 */
public class DivideStep {

	private Integer pivotIndex;

	private List<Integer> subList;

	public DivideStep(List<Integer> subList) {

		this.subList = subList;
	}

	public Integer getPivotIndex() {
		return pivotIndex;
	}

	public void setPivotIndex(Integer pivotIndex) {
		this.pivotIndex = pivotIndex;
	}
	
	

	public List<Integer> getSubList() {
		return subList;
	}

	public DivideStep getLeftPartition() {

		List<Integer> leftSubList = (List<Integer>) SortUtil.safeGetSublist(subList, 0,
				pivotIndex);

		return new DivideStep(leftSubList);

	}

	public DivideStep getRightPartition() {

		List<Integer> rightSubList = (List<Integer>) SortUtil.safeGetSublist(subList,
				pivotIndex + 1, subList.size());

		return new DivideStep(rightSubList);
	}

}
